<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        table{
            border: 1px solid;
            margin: auto;
            width: 500px;
        }

        td,th{
            text-align: center;
            border: 1px solid;
        }
        div{
            text-align: center;
            margin: 50px;
        }
    </style>
</head>
<body>
    <div>
        <input type="text" id="name" placeholder="请输入姓名" autocomplete="off">
        <input type="text" id="age"  placeholder="请输入年龄" autocomplete="off">
        <input type="text" id="gender"  placeholder="请输入性别" autocomplete="off">
        <input type="button" value="添加" id="add">
    </div>
    <table>
        <caption>学生信息表</caption>
        <tr>
            <th>姓名</th>
            <th>年龄</th>
            <th>性别</th>
            <th>操作</th>
        </tr>
        <tr>
            <td>张三</td>
            <td>23</td>
            <td>男</td>
            <td><button type="button" onclick="del(this)">删除</button></td>
        </tr>
    </table>
</body>
    <script>
        document.querySelectorAll("input")[3].onclick = function(){
            let name = document.querySelectorAll("input")[0].value;
            let age = document.querySelectorAll("input")[1].value;
            let gender = document.querySelectorAll("input")[2].value;

            let tr =`<tr><td>${name}</td><td>${age}</td><td>${gender}</td><td><button type="button" onclick="del(this)">删除</button></td></tr>`;

            document.querySelector("tbody").innerHTML +=tr;
        };


        function del(current){
            let tr = current.parentNode.parentNode;

            document.querySelector("tbody").removeChild(tr);
        }

    </script>
</html>